]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/entry: Invalidate text shadow on style changes to ClutterText
authorJonas Dreßler <verdre@v0yd.nl>
Fri, 5 Mar 2021 11:17:07 +0000 (12:17 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 14 Feb 2022 12:52:20 +0000 (12:52 +0000)
We update a few properties of ClutterText when the CSS changes via
_st_set_text_from_style() (which we call when receiving the
style-changed signal).

Right now we simply invalidate the text shadow every time we receive the
style-changed signal, but we're going to change that with the next
commits. To ensure the shadow still gets invalidated on CSS changed that
might affect the shadow, listen to a bunch of property changes that will
get notified when any property that affects the shadow changes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1744>

src/st/st-entry.c

index d50c2548bd1b75e89fb93755e39fdbe86d2db82d..e2e985df67f0251c9b96be0c20830ce507310a22 100644 (file)
@@ -562,6 +562,16 @@ clutter_text_changed_cb (GObject    *object,
   g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]);
 }
 
+static void
+invalidate_shadow_pipeline (GObject    *object,
+                            GParamSpec *pspec,
+                            StEntry    *entry)
+{
+  StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
+
+  g_clear_pointer (&priv->text_shadow_material, cogl_object_unref);
+}
+
 static void
 st_entry_clipboard_callback (StClipboard *clipboard,
                              const gchar *text,
@@ -1058,6 +1068,20 @@ st_entry_init (StEntry *entry)
   g_signal_connect (priv->entry, "notify::text",
                     G_CALLBACK (clutter_text_changed_cb), entry);
 
+  /* These properties might get set from CSS using _st_set_text_from_style */
+  g_signal_connect (priv->entry, "notify::font-description",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::attributes",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::justify",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::line-alignment",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+
   priv->spacing = 6.0f;
 
   priv->text_shadow_material = NULL;